package com.yonyou.cyxdms.sysAuth.service.mapper;

import java.util.List;
import java.util.Map;
import java.util.Set;

import com.yonyou.cyxdms.sysAuth.service.dto.user.UserAndRoleClaimDTO;
import com.yonyou.cyxdms.sysAuth.service.entity.cms.ConsultantVo;
import com.yonyou.cyxdms.sysAuth.service.entity.cms.GetUserInfoByjwtVO;
import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yonyou.cyx.framework.dao.base.SuperMapper;
import com.yonyou.cyxdms.framework.bean.dto.user_info.LoginInfoDto;
import com.yonyou.cyxdms.sysAuth.service.controller.DbUnionCommonDto;
import com.yonyou.cyxdms.sysAuth.service.dto.UserDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.broker.BrokerByDlerIdDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.broker.BrokerCardVo;
import com.yonyou.cyxdms.sysAuth.service.dto.broker.BrokerDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.broker.BrokerInfoVO;
import com.yonyou.cyxdms.sysAuth.service.dto.broker.BrokerVO;
import com.yonyou.cyxdms.sysAuth.service.dto.user.UserAndRoleDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.user.UserPermissionActionListDTO;
import com.yonyou.cyxdms.sysAuth.service.entity.UserPO;
import com.yonyou.cyxdms.sysAuth.service.vo.employee.EmployeeAddVO;
import com.yonyou.cyxdms.sysAuth.service.vo.employee.UserEmpInfoVO;
import com.yonyou.cyxdms.sysAuth.service.vo.user.CompanyUserVO;
import com.yonyou.cyxdms.sysAuth.service.vo.user.UserEmpVO;
import com.yonyou.cyxdms.sysAuth.service.vo.user.UserInfosVO;
import com.yonyou.cyxdms.sysAuth.service.vo.user.UserRoleVO;
import com.yonyou.cyxdms.sysmanage.client.domains.dto.UserDictDto;
import com.yonyou.cyxdms.sysmanage.client.vo.employee.UserInfoVO;

/**
 * <p>
 * 账号信息 Mapper 接口
 * </p>
 *
 * @author quankk
 * @since 2019-03-07
 */
public interface UserMapper extends SuperMapper<UserPO> {
    List<UserDTO> userByCondition(UserDTO userDTO);

    int deleteByEmployeeId(@Param("employeeId") Integer employeeId);

    LoginInfoDto getUserInfoByCode(@Param("userCode") String userCode,
                                   @Param("appId") String appId);

    UserPO selectByAppUserId(@Param("appId") String appId, @Param("userId") Long userId);

    UserPO selectByAppUserCode(@Param("appId") String appId, @Param("userCode") String userCode);

    UserPO selectByAppUserCodeOr(@Param("appId") String appId, @Param("userCode") String userCode);



    Integer getDealerIdByUserId(@Param("userId") Integer userId);

    Integer getDealerIdByDealerCode(@Param("dealerCode") String dealerCode);

    String getDealerCodeByDealerId(@Param("dealerId") Integer dealerId);

    Map<String, Object> getUserInfoByPass(@Param("userName") String userName, @Param("passWord") String passWord, @Param("appId") String appId);

    Long getEmployeeIdByUserCode(@Param("appId") String appId, @Param("userCode") String userCode);

    UserEmpVO findUserById(@Param("id") Long id);

    List<Map> findEmpRolesByEmpId(@Param("id") Long id);

    UserEmpVO findUserByEmployeeId(@Param("id") Long id);

    /**
     * @author ：quankk
     * @date ：2019/7/18 15:24
     * @description：用户密码查询用户信息
     */
    List<UserInfosVO> searchUserInfos(Page<UserInfosVO> page, @Param("param") Map<String, String> param);


    /**
     * <p>通过employeeid获取userid的数组
     *
     * @author maxigjian
     * @since 2019-09-18
     */
    List<Map> findUserIdByEmployeeId(@Param("id") Long id);


    /**
     * <p>通过usercode获取usertype数据
     *
     * @author maxigjian
     * @since 2019-09-18
     */
    List<Map> getUserTypeByUserCode(@Param("userCode") String userCode, @Param("appId") String appId);

    /**
     * <p>通过usercode获取tm_emp数据
     *
     * @author maxigjian
     * @since 2019-09-18
     */
    List<Map> getEmpByUserCode(@Param("userCode") String userCode, @Param("appId") String appId);

    Integer getDealerIsFixed(@Param("companyId") Long companyId);

    public List<UserDTO> getJueSe(@Param("params") DbUnionCommonDto searchEntity);

    public List<UserDTO> getUserInformation(@Param("params") DbUnionCommonDto searchEntity);

    public boolean updateById(UserDTO userDTO);

    public UserDTO checkUserExect(@Param("params") DbUnionCommonDto searchEntity);

    public UserDTO checkUserRole(@Param("params") DbUnionCommonDto searchEntity);

    public UserDTO checkUserRoleMain(@Param("params") DbUnionCommonDto searchEntity);

    public UserDTO checkUserCstop(@Param("params") DbUnionCommonDto searchEntity);

    int updateHead(String head, String vx, String userid);

    public UserDictDto getUserById(@Param("userId") Long userId);

    /**
     * 获取名片信息
     *
     * @param uid
     * @return
     * @auth houkh
     */
    BrokerVO getBrokerCard(Long uid);

    /**
     * 批量查询用户信息
     *
     * @param userTokens
     * @return
     */
    List<BrokerDTO> getBrokersByUids(@Param("userIds") List<String> userTokens);

    /**
     * 模糊查询顾问信息
     *
     * @param appId
     * @param forWord
     * @return
     * @auth houkh
     */
    List<BrokerInfoVO> queryBrokerInfo(@Param("appId") String appId, @Param("forWord") String forWord);

    /**
     * @param dealerId
     * @return
     * @auth houkh
     */
    List<BrokerByDlerIdDTO> selectUserListByDealerId(@Param("dealerId") String dealerId);


    /**
     * @param dealerId
     * @return
     * @auth houkh
     */
    List<BrokerByDlerIdDTO> selectUserListByDealerCode(@Param("dealerId") String dealerId);

    /**
     * H5获取销售顾问信息 销售顾问id
     *
     * @param brokerId 销售顾问id
     * @return java.util.Map<java.lang.String               ,               java.lang.Object>
     * @author renwd
     * @since 2018/9/21
     */
    public Map<String, Object> findBrokerInfo(@Param(value = "brokerId") Long brokerId, @Param(value = "appId") String appId);

    LoginInfoDto getUserInfoById(@Param("appId") String appId, @Param("userId") Long userId);

    /**
     * 根据角色类别获取用户信息信息
     *
     * @param companyId
     * @param appId
     * @param role
     * @return
     * @author 李贺
     * @since 2019/9/4
     */
    List<UserAndRoleDTO> getUserListByRole(@Param("companyId") Long companyId, @Param("appId") String appId, @Param("role") Integer role);

    List<UserAndRoleClaimDTO> getUserListByRoleClaim(@Param("companyId") Long companyId, @Param("appId") String appId, @Param("role") String role);


    List<BrokerCardVo> getBrokerInfo(@Param("appId") String appId,
                                     @Param("userIds") List<String> userIds,
                                     @Param("userCodes") List<String> userCodes);

    /**
     * 查询登录用户信息
     *
     * @return
     * @author 李贺
     * @date 2019年9月18日
     */
    EmployeeAddVO findEmployeeById(@Param("employeeId") Long employeeId);


    List<UserInfoVO> getUserInfoByUserId(@Param("userId") Long userId);

    List<UserInfoVO> getUserInfoList(@Param("userIdSet") Set<String> userIdSet);

    List<UserInfoVO> getUserInfoByParams(Page<UserInfoVO> page, @Param("params") Map<String, Object> params);

    UserEmpInfoVO findInfo(@Param("employeeNo") String employeeNo);

    List<UserPermissionActionListDTO> getUserPermissionAction(@Param("permissionId") Long permissionId, @Param("billType") int billType);

    /**
     * 根据userId和userOrgId返回角色类别
     *
     * @date 2019-10-28  adu
     */
    Map<String, Object> getRoleTypeParams(@Param("userId") Integer userId, @Param("orgId") Integer orgId);

    Long updateFailureNum();

    void updateByRegId(@Param("regId") String regId);

    Integer findNeedUpdate(@Param("userId") Long userId, @Param("paramValue") Integer paramValue);

    List<CompanyUserVO> getAllUser(@Param("companyId") Long companyId, @Param("appId") String appId);

    String getPositionCodeByUserOrgId(@Param("userOrgId") Long userOrgId);

    List<UserRoleVO> getRoleInfoByCompanyId(@Param("companyId") String companyId, @Param("appId") String appId);

    List<ConsultantVo> selectConsultantInfo();

    public UserDictDto getUserByIdCMS(@Param("userId") Long userId);

    List<GetUserInfoByjwtVO> getUserInfoByUId(@Param("userId") String userId);

    List<GetUserInfoByjwtVO> getUserInfoByUIdCMS(@Param("userId") String userId);

    UserDictDto getUserByIdCMSNew(@Param("userId") Long userId, @Param("userOrgId") String userOrgId);

    List<UserEmpVO> findNameByIds(@Param("userIds") String[] userIds);

    List<UserEmpVO> findUserByRole(@Param("params") Map params);

    Integer checkEmployeeStatus(@Param("appId")String appId,@Param("userId") Long userId);

    List<UserEmpVO> findNameByAppId(@Param("appId") String appId);
}
